/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uit.qlks.controller.loaiphong;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.rowset.WebRowSet;
import uit.ejb.bo.loaiphong.LoaiPhongBORemote;
import uit.ejb.bo.loaiphong.LoaiPhongBORemoteHome;
import uit.ejb.dto.LoaiPhongDTO;

/**
 *
 * @author Restart
 */
public class LoaiPhongCotroller {

    private static Context ctx;
    private static LoaiPhongBORemoteHome phome;
    private static LoaiPhongBORemote lp;
    public LoaiPhongCotroller(){
    }
    public static void Register(){
        try{
            ctx = new InitialContext();
            Object obj = ctx.lookup("ejb/LoaiPhongBO");
            phome = (LoaiPhongBORemoteHome) PortableRemoteObject.narrow(obj, LoaiPhongBORemoteHome.class);
            lp=phome.create();
        }
        catch(Exception e){
        }
    }

    public static boolean loaiPhong_Insert(LoaiPhongDTO loaiphong) {
        try {
            Register();
            return lp.loaiPhong_Insert(loaiphong);
        } catch (Exception e) {
            e.getMessage();
            return false;
        }
    }

    public static boolean loaiPhong_Update(LoaiPhongDTO loaiphong) {
        try {
            Register();
            return lp.loaiPhong_Update(loaiphong);
        } catch (Exception e) {
            e.getMessage();
            return false;
        }
    }

    public static boolean loaiPhong_Delete(String id) {
        try {
            Register();
            return lp.loaiPhong_Delete(id);
        } catch (Exception e) {
            e.getMessage();
            return false;
        }
    }

    public static WebRowSet loaiPhong_GetByAll() {
        try {
            Register();
            return lp.loaiPhong_GetByAll();
        } catch (Exception e) {
            e.getMessage();
            return null;
        }
    }

    public static WebRowSet loaiPhong_GetById(String id) {
        try {
            Register();
            return lp.loaiPhong_GetById(id);
        } catch (Exception e) {
            e.getMessage();
            return null;
        }
    }
}
